var e = getApp();

Page({
    data: {
        language: "",
        selected: "0",
        display: 1,
        pagesize: 1,
        wait_used: [],
        overdue: [],
        used: [],
        loading: !1,
        allLoaded: !1,
        goload: !0,
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        coin_name: "",
        usable: 0,
        type: ""
    },
    onLoad: function(e) {
        if (console.log(e.type, "类型"), this.setData({
            type: e.type || ""
        }), "FrozenCoin" == e.type) return this.getAllData(0), void this.setData({
            coin_name: ""
        });
        this.setData({
            selected: "0"
        }), this.getUsable(), this.getNetData(0);
    },
    onReady: function() {
        var e = wx.getStorageSync("langIndex");
        this.setData({
            language: e.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getUsable: function() {
        var t = this, a = e.getNetAddresss("plugin.coin.Frontend.Controllers.page.index");
        e._getNetWork({
            url: a,
            success: function(e) {
                1 === e.data.result ? (t.setData({
                    usable: e.data.data.usable,
                    coin_name: e.data.data.coin_name
                }), wx.setNavigationBarTitle({
                    title: e.data.data.coin_name ? e.data.data.coin_name + "明细" : "明细"
                })) : wx.showToast({
                    title: e.data.msg,
                    icon: "none"
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    onChange: function(e) {
        "FrozenCoin" != this.data.type ? this.getNetData(e.detail.index) : this.getAllData(e.detail.index);
    },
    getNetData: function(t) {
        var a = this, n = e.getNetAddresss("plugin.coin.Frontend.Modules.Coin.Controllers.change-records.index");
        n += "&service_type=" + t, n += "&page=1", e._getNetWork({
            url: n,
            success: function(e) {
                if (1 === e.data.result) {
                    var n = e.data.data;
                    a.setData({
                        total_page: e.data.data.last_page
                    }), 0 == t ? a.setData({
                        overdue: [],
                        used: [],
                        wait_used: n.data
                    }) : 1 == t ? a.setData({
                        wait_used: [],
                        overdue: n.data,
                        used: []
                    }) : 2 == t && a.setData({
                        wait_used: [],
                        overdue: [],
                        used: n.data
                    });
                } else wx.showToast({
                    title: e.data.msg,
                    icon: "none"
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    getAllData: function(t) {
        var a = this, n = e.getNetAddresss("plugin.froze.Frontend.Modules.Froze.Controllers.records.index");
        n += "&service_type=" + t, n += "&page=1", e._getNetWork({
            url: n,
            success: function(e) {
                if (1 === e.data.result) {
                    var n = e.data.data;
                    0 == t ? a.setData({
                        overdue: [],
                        used: [],
                        wait_used: n.data
                    }) : 1 == t ? a.setData({
                        wait_used: [],
                        overdue: n.data,
                        used: []
                    }) : 2 == t && a.setData({
                        wait_used: [],
                        overdue: [],
                        used: n.data
                    });
                } else wx.showToast({
                    title: e.data.msg,
                    icon: "none"
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    }
});